var e = require("../../@babel/runtime/helpers/regeneratorRuntime"),
  t = require("../../@babel/runtime/helpers/objectSpread2"),
  r = require("../../@babel/runtime/helpers/asyncToGenerator"),
  n = require("../../store/index"),
  o = require("../../utils/index"),
  a = require("../../config/index"),
  s = o.helper.tabCommon,
  i = o.helper.classifyCity,
  c = o.tools.common.getHeaderHeight,
  u = $.getMenuButtonBoundingClientRect().top,
  l = s.getmodeStorageKey(a.typeMode.recruit);

function f() {
  return h.apply(this, arguments)
}

function h() {
  return (h = r(e().mark((function t() {
    var r, n, o;
    return e().wrap((function (e) {
      for (;;) switch (e.prev = e.next) {
        case 0:
          r = s.getFilterParamsInfo(l), n = r.sort, o = r.type, this.setData({
            pickTypeLabel: (null == o ? void 0 : o.label) || "",
            sortPick: n || {}
          });
        case 2:
        case "end":
          return e.stop()
      }
    }), t, this)
  })))).apply(this, arguments)
}
Page({
  componentPage: ["onReachBottom", "onPullDownRefresh", "onPageScroll"],
  useStore: function (e) {
    return {
      isShowFreeInviteDialog: e.global.isShowFreeInviteDialog,
      sortClass: e.global.sortClass.filter((function (e) {
        return 3 !== e.id
      }))
    }
  },
  data: {
    delayRender: !1,
    navHeight: c("14rpx"),
    sortPickerTop: "calc(96rpx + ".concat(c("14rpx")),
    headerTop: u,
    showTypePicker: !1,
    showSortPicker: !1,
    pickTypeLabel: "",
    sortPick: ""
  },
  onSwitchTypePicker: function () {
    this.setData({
      showTypePicker: !this.data.showTypePicker
    })
  },
  onSwitchSortPicker: function () {
    this.setData({
      showSortPicker: !this.data.showSortPicker
    })
  },
  onSortFilterChange: function (n) {
    var o = this;
    return r(e().mark((function r() {
      var a;
      return e().wrap((function (e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            return a = s.getFilterParamsInfo(l), e.next = 3, s.setFilterParamsInfo(l, t(t({}, a), {}, {
              sort: n.detail || ""
            }));
          case 3:
            o.scrollAndRefresh(), f.call(o);
          case 5:
          case "end":
            return e.stop()
        }
      }), r)
    })))()
  },
  onTypeFilterChange: function () {
    var t = this;
    return r(e().mark((function r() {
      return e().wrap((function (e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            return e.next = 2, t.scrollAndRefresh();
          case 2:
            f.call(t);
          case 3:
          case "end":
            return e.stop()
        }
      }), r)
    })))()
  },
  onClearSelectLabel: function (t) {
    var n = this;
    return r(e().mark((function r() {
      var o;
      return e().wrap((function (e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            return o = t.target.dataset.type, e.next = 3, s.clearKeyStorage(l, o);
          case 3:
            return e.next = 5, n.scrollAndRefresh();
          case 5:
            f.call(n);
          case 6:
          case "end":
            return e.stop()
        }
      }), r)
    })))()
  },
  onLoad: function () {
    var e = this,
      t = setTimeout((function () {
        clearTimeout(t), e.setData({
          delayRender: !0
        })
      }), 1100);
    this.onRefresh()
  },
  onRefresh: function () {
    $.selectComponent.call(this, "#card-list").then((function (e) {
      return e.onRefresh()
    }))
  },
  onSearch: function (e) {
    this.scrollAndRefresh({
      keywords: e.detail || ""
    })
  },
  onShow: function () {
    var t = this;
    return r(e().mark((function r() {
      var n, o;
      return e().wrap((function (e) {
        switch (e.prev = e.next) {
          case 0:
            return n = $.router.getParams(), e.next = 3, i.cityOrClassifyChange(t.oldUserLocationCity, t.oldTypeClassify);
          case 3:
            if (o = e.sent, e.t0 = null != n && n.isMultiRoleSelectUpdate || o, !e.t0) {
              e.next = 8;
              break
            }
            return e.next = 8, t.scrollAndRefresh();
          case 8:
            f.call(t);
          case 9:
          case "end":
            return e.stop()
        }
      }), r)
    })))()
  },
  onHide: function () {
    var o = this;
    return r(e().mark((function r() {
      var a, i;
      return e().wrap((function (e) {
        switch (e.prev = e.next) {
          case 0:
            a = n.store.getState().storage.userLocationCity, o.oldUserLocationCity = t({}, a), i = s.getFilterParamsInfo(l), o.oldTypeClassify = i;
          case 4:
          case "end":
            return e.stop()
        }
      }), r)
    })))()
  },
  scrollAndRefresh: function (t) {
    var n = this;
    return r(e().mark((function a() {
      return e().wrap((function (a) {
        for (;;) switch (a.prev = a.next) {
          case 0:
            $.selectComponent.call(n, "#card-list").then(function () {
              var n = r(e().mark((function r(n) {
                return e().wrap((function (e) {
                  for (;;) switch (e.prev = e.next) {
                    case 0:
                      if (e.t0 = t, !e.t0) {
                        e.next = 4;
                        break
                      }
                      return e.next = 4, n.setExtraParames(t);
                    case 4:
                      return e.next = 6, n.setRefresh(!0);
                    case 6:
                      return e.next = 8, n.onRefresh();
                    case 8:
                      return e.next = 10, o.operateDom.moveToTop();
                    case 10:
                      return e.next = 12, n.setRefresh(!1);
                    case 12:
                    case "end":
                      return e.stop()
                  }
                }), r)
              })));
              return function (e) {
                return n.apply(this, arguments)
              
              }
            }());
          case 1:
          case "end":
            return a.stop() 
        }
      }), a)
    })))()
  },
  onCloseInvite: function () {
    (0, n.dispatch)(n.actions.globalActions.setState({
      isShowFreeInviteDialog: !1
    }))
  }
});